zIndex = 500

S.dialog = {}
S.dialog.show = (options)->
    ctx = {}
    zIndex++
    $modal = $('<div>', class: 'dialog-modal').css(zIndex: zIndex).appendTo($('body'))
    ctx.$modal = $modal
    $dialog = $('<div>', class: 'dialog').appendTo($modal)
    $dialog.append options.content
    ctx.$dialog = $dialog

    dialogTop = ($modal[0].scrollHeight - $dialog[0].scrollHeight) * 0.35
    $dialog.css {top: dialogTop + 'px'}

    ctx.close = ->
        $modal.remove()
    return ctx